home *** CD-ROM | disk | FTP | other *** search
- Path: global.gc.net!sourcebbs!david.mohorn
- From: david.mohorn@sourcebbs.com (DAVID MOHORN)
- Newsgroups: comp.lang.c
- Subject: COLLEGE PROFESSORS! # 1/2
- Message-ID: <8BEC555.02C70031C3.uuout@sourcebbs.com>
- Date: Tue, 16 Apr 96 22:45:00 -0500
- Distribution: world
- Organization: SelectiveSourceBBS VirginiaBeach (804)471 6776
- Reply-To: david.mohorn@sourcebbs.com (DAVID MOHORN)
- X-Newsreader: PCBoard Version 15.22
- X-Mailer: PCBoard/UUOUT Version 1.20
-
- I can't stand it! I cannot believe the way my VisualBASIC instructor at
- college is teaching his students to program. He and I had it out during
- class tonight over this programming construct, which I will demonstrate
- in pseudocode.
-
- This routine is called only to validate a string that is passed and
- return a condition, either GOOD or BAD:
-
- EXAMPLE 1:
- *** start of validation routine ***
- declare StatusSwitch string
-
- define StatusSwitch string as "GOOD"
-
- if( condition1 ) then
- else
- display error message
- set StatusSwitch="BAD"
-
- if( condition2 and StatusSwitch="GOOD" ) then
- else
- display error message
- set StatusSwitch="BAD"
-
- if( condition3 and StatusSwitch="GOOD" ) then
- else
- display error message
- set StatusSwitch="BAD"
-
- if( condition4 and StatusSwitch="GOOD" ) then
- else
- display error message
- set StatusSwitch="BAD"
-
- return StatusSwitch
- *** end of validation routine ***
-
- versus the simple, yet elegant approach of:
-
- EXAMPLE 2:
- *** start of validation routine ***
- declare StatusSwitch string
-
- define StatusSwitch string as "GOOD"
-
- if( condition1 ) then
- else
- display error message
- return StatusSwitch
-
- if( condition2 ) then
- else
- display error message
- return StatusSwitch
-
- if( condition3 ) then
- else
- display error message
- return StatusSwitch
-
- if( condition4 ) then
- else
- display error message
- return StatusSwitch
-
- return StatusSwitch
- *** end of validation routine ***
-
- or even a better approach:
-
- EXAMPLE 3:
- *** start of validation routine ***
- declare StatusSwitch string
-
- define StatusSwitch string as "GOOD"
-
- if( condition1 ) then
- else
- display error message
- return StatusSwitch
- else
- if( condition2 ) then else
- display error message
- return StatusSwitch
- else
- if( condition3 ) then
- else
- display error message
- return StatusSwitch
- else
- if( condition4 ) then
- else
- display error message
- return StatusSwitch
-
- (Continued to next message)
- ---
- * QMPro 1.53 * Programming is 10% inspiration and 90% debugging.
-
-
- ---
- This message originated from: ---------- Selective Source BBS
- ------- Virginia Beach, Virginia
- ----- (804) 471 6776
-